package org.teamh.gui.engine.fbo;

import static org.lwjgl.opengl.GL11.*;

public class Draw2D {

        private Draw2D() {}
        
        public static void drawImage(int texture, int x, int y, int width, int height) {
                glEnable(GL_TEXTURE_2D);
                glBindTexture(GL_TEXTURE_2D, texture);
                
                drawImage(x, y, width, height, 0, 0, 1, 1);
                
                glDisable(GL_TEXTURE_2D);
        }
        
        public static void drawImage(int texture, int x, int y, int width, int height, float depth) {
                glEnable(GL_TEXTURE_2D);
                glBindTexture(GL_TEXTURE_2D, texture);
                
                drawImage(x, y, width, height, 0, 0, 1, 1, depth);
                
                glDisable(GL_TEXTURE_2D);
        }
        
        public static void drawImage(int x, int y, int width, int height, float texX, float texY, float texWidth, float texHeight) {
                glBegin(GL_QUADS);
                {
                        glTexCoord2f(texX, texY + texHeight);
                        glVertex2i(x, y);
                        glTexCoord2f(texX + texWidth, texY + texHeight);
                        glVertex2i(x + width, y);
                        glTexCoord2f(texX + texWidth, texY);
                        glVertex2i(x + width, y + height);
                        glTexCoord2f(texX, texY);
                        glVertex2i(x, y + height);
                }
                glEnd();
        }
        
        public static void drawImage(int x, int y, int width, int height, float texX, float texY, float texWidth, float texHeight, float depth) {
                glBegin(GL_QUADS);
                {
                        glTexCoord2f(texX, texY + texHeight);
                        glVertex3f(x, y, depth);
                        glTexCoord2f(texX + texWidth, texY + texHeight);
                        glVertex3f(x + width, y, depth);
                        glTexCoord2f(texX + texWidth, texY);
                        glVertex3f(x + width, y + height, depth);
                        glTexCoord2f(texX, texY);
                        glVertex3f(x, y + height, depth);
                }
                glEnd();
        }
        
        public static void drawRect(int x, int y, int width, int height) {
                glBegin(GL_LINE_STRIP);
                {
                        glVertex2i(x, y);
                        glVertex2i(x + width, y);
                        glVertex2i(x + width, y + height);
                        glVertex2i(x, y + height);
                        glVertex2i(x, y);
                }
                glEnd();
        }
        
        public static void fillRect(int x, int y, int width, int height) {
                glBegin(GL_QUADS);
                {
                        glVertex2i(x, y);
                        glVertex2i(x + width, y);
                        glVertex2i(x + width, y + height);
                        glVertex2i(x, y + height);
                }
                glEnd();
        }
}
